Pour installe ArchiSimple :
g++ *.cpp external/tinyxml2/tinyxml2.cpp -std=c++11 -o archisimple.exe
(dans le terminal au directory ArchiSimple93)
archisimple.exe
ArchiSimple <- function(par,exporttype,time) {
setwd("ArchiSimple/src/archisimple93/")
inc <-0
for (variety in par$exportName) {
# Print l'avancé de la boucle
inc <- inc+1
print(paste("Simulation pour :", variety, "i=", inc, '========================'))
#Update les paramètres
## Regarde chaque colone de params, si la même est dans par, il remplace la colonne de params par celle de par
params <- params %>%
mutate(across(everything(), ~ ifelse(cur_column() %in% names(par), par[inc,][[cur_column()]],.))) %>%
mutate(exportType = exporttype) %>%
mutate(simtime=time)
print(params)
# Créaction du fichier paramètre lu par ArchiSimple
write_archisimple_XML(params, path = "parameter.xml")
# Run ArchiSimple
system("./archisimple")
}
setwd("../../../")
}# Fonction qui fait un plot pour chaque jour jusqu'à jour max
time_plot <- function(data, variety) {
for (i in 1:8) {
print(i)
print(paste('Plot pour',variety,'jour',i*5))
print(
filter(sims,sim==variety, Jour <= i*5) %>%
ggplot() +
theme_classic() +
geom_segment(aes(x = X1, y = -Z1, xend = X2, yend = -Z2, color=Diam), alpha=0.9) +
scale_x_continuous(limits=c(-500,+500)) +
scale_y_continuous(limits = c(-2000, 0)) +
scale_color_viridis(limits=c(0,2.5),option = "turbo") +
coord_fixed()+
labs(title=paste(variety,'jour',i*5),col='Diamètre')
)
}
}Importe le fichier ‘base_parameter.xml’ ainsi qu’un dataframe avec les valeurs qui doivent être modifiées.
# Import des paramètres de base
params <- read_archisimple_xml("base_parameter.xml")
# Insérer les différents paramètres à modifier dans le batch
par_sorgho <- data.frame(
exportName=c('Amiggo','Biggben','Hyperion','Juno','Swingg','Vegga'),
dmin=c( 0.1567 ,0.1567 ,0.1567 ,0.1567 ,0.1567 ,0.1297),
RDM = c( 0.1874 ,0.2022 ,0.228 ,0.17545 ,0.1745 ,0.1611)
)ArchiSimple(par=par_sorgho,exporttype = 1,time = 40)## [1] "Simulation pour : Amiggo i= 1 ========================"
## # A tibble: 1 × 27
## ageAdv CVDD dAdv distAdv dmax dmin dSem EL erAdv erSem exportName
## <chr> <chr> <chr> <chr> <chr> <dbl> <chr> <chr> <chr> <chr> <chr>
## 1 12 0.2449 0.3407 30 6.984537 0.157 0.08… 33.0… 1.2 1 Amiggo
## # ℹ 16 more variables: exportType <dbl>, GDs <chr>, IPD <chr>, LDC <chr>,
## # maxAdv <chr>, maxSem <chr>, pdmax <chr>, pdmin <chr>, PDT <chr>, RDM <dbl>,
## # SGC <chr>, sim_length <chr>, simtime <dbl>, TMD <chr>, TrInt <chr>,
## # TrT <chr>
## [1] "Simulation pour : Biggben i= 2 ========================"
## # A tibble: 1 × 27
## ageAdv CVDD dAdv distAdv dmax dmin dSem EL erAdv erSem exportName
## <chr> <chr> <chr> <chr> <chr> <dbl> <chr> <chr> <chr> <chr> <chr>
## 1 12 0.2449 0.3407 30 6.984537 0.157 0.08… 33.0… 1.2 1 Biggben
## # ℹ 16 more variables: exportType <dbl>, GDs <chr>, IPD <chr>, LDC <chr>,
## # maxAdv <chr>, maxSem <chr>, pdmax <chr>, pdmin <chr>, PDT <chr>, RDM <dbl>,
## # SGC <chr>, sim_length <chr>, simtime <dbl>, TMD <chr>, TrInt <chr>,
## # TrT <chr>
## [1] "Simulation pour : Hyperion i= 3 ========================"
## # A tibble: 1 × 27
## ageAdv CVDD dAdv distAdv dmax dmin dSem EL erAdv erSem exportName
## <chr> <chr> <chr> <chr> <chr> <dbl> <chr> <chr> <chr> <chr> <chr>
## 1 12 0.2449 0.3407 30 6.984537 0.157 0.08… 33.0… 1.2 1 Hyperion
## # ℹ 16 more variables: exportType <dbl>, GDs <chr>, IPD <chr>, LDC <chr>,
## # maxAdv <chr>, maxSem <chr>, pdmax <chr>, pdmin <chr>, PDT <chr>, RDM <dbl>,
## # SGC <chr>, sim_length <chr>, simtime <dbl>, TMD <chr>, TrInt <chr>,
## # TrT <chr>
## [1] "Simulation pour : Juno i= 4 ========================"
## # A tibble: 1 × 27
## ageAdv CVDD dAdv distAdv dmax dmin dSem EL erAdv erSem exportName
## <chr> <chr> <chr> <chr> <chr> <dbl> <chr> <chr> <chr> <chr> <chr>
## 1 12 0.2449 0.3407 30 6.984537 0.157 0.08… 33.0… 1.2 1 Juno
## # ℹ 16 more variables: exportType <dbl>, GDs <chr>, IPD <chr>, LDC <chr>,
## # maxAdv <chr>, maxSem <chr>, pdmax <chr>, pdmin <chr>, PDT <chr>, RDM <dbl>,
## # SGC <chr>, sim_length <chr>, simtime <dbl>, TMD <chr>, TrInt <chr>,
## # TrT <chr>
## [1] "Simulation pour : Swingg i= 5 ========================"
## # A tibble: 1 × 27
## ageAdv CVDD dAdv distAdv dmax dmin dSem EL erAdv erSem exportName
## <chr> <chr> <chr> <chr> <chr> <dbl> <chr> <chr> <chr> <chr> <chr>
## 1 12 0.2449 0.3407 30 6.984537 0.157 0.08… 33.0… 1.2 1 Swingg
## # ℹ 16 more variables: exportType <dbl>, GDs <chr>, IPD <chr>, LDC <chr>,
## # maxAdv <chr>, maxSem <chr>, pdmax <chr>, pdmin <chr>, PDT <chr>, RDM <dbl>,
## # SGC <chr>, sim_length <chr>, simtime <dbl>, TMD <chr>, TrInt <chr>,
## # TrT <chr>
## [1] "Simulation pour : Vegga i= 6 ========================"
## # A tibble: 1 × 27
## ageAdv CVDD dAdv distAdv dmax dmin dSem EL erAdv erSem exportName
## <chr> <chr> <chr> <chr> <chr> <dbl> <chr> <chr> <chr> <chr> <chr>
## 1 12 0.2449 0.3407 30 6.984537 0.130 0.08… 33.0… 1.2 1 Vegga
## # ℹ 16 more variables: exportType <dbl>, GDs <chr>, IPD <chr>, LDC <chr>,
## # maxAdv <chr>, maxSem <chr>, pdmax <chr>, pdmin <chr>, PDT <chr>, RDM <dbl>,
## # SGC <chr>, sim_length <chr>, simtime <dbl>, TMD <chr>, TrInt <chr>,
## # TrT <chr>
setwd("ArchiSimple/src/archisimple93/")
sims <- NULL
for (variety in c('Amiggo','Biggben','Hyperion','Juno','Swingg','Vegga')) {
rs <- fread(paste0(variety,'.txt')) %>%
mutate(sim = as.factor(variety))
sims <- rbind(sims,rs)
}
setwd("../../../") for (variety in levels(sims$sim)) {
time_plot(sims,variety = variety)
print(paste('La profondeur max du système racinaire après 40 jours=',max(subset(sims,sim==variety)$Z1),'[mm]'))
print(paste0('Le système racinaire après 40 jours s étend de',min(subset(sims,sim==variety)$X1),'[mm] à ',max(subset(sims,sim==variety)$X1),'[mm] soit une largeur totale de :',
max(subset(sims,sim==variety)$X1)-min(subset(sims,sim==variety)$X1),'[mm]'))
print(paste('Le diamètre moyen des racines après 40 jours est =',mean(subset(sims, sim==variety)$Diam)))
}## [1] 1
## [1] "Plot pour Amiggo jour 5"
## [1] 2
## [1] "Plot pour Amiggo jour 10"
## [1] 3
## [1] "Plot pour Amiggo jour 15"
## [1] 4
## [1] "Plot pour Amiggo jour 20"
## [1] 5
## [1] "Plot pour Amiggo jour 25"
## [1] 6
## [1] "Plot pour Amiggo jour 30"
## [1] 7
## [1] "Plot pour Amiggo jour 35"
## [1] 8
## [1] "Plot pour Amiggo jour 40"
## Warning: Removed 4 rows containing missing values (`geom_segment()`).
## [1] "La profondeur max du système racinaire après 40 jours= 1633.62 [mm]"
## [1] "Le système racinaire après 40 jours s étend de-496.42[mm] à 507.29[mm] soit une largeur totale de :1003.71[mm]"
## [1] "Le diamètre moyen des racines après 40 jours est = 0.641676020622769"
## [1] 1
## [1] "Plot pour Biggben jour 5"
## [1] 2
## [1] "Plot pour Biggben jour 10"
## [1] 3
## [1] "Plot pour Biggben jour 15"
## [1] 4
## [1] "Plot pour Biggben jour 20"
## [1] 5
## [1] "Plot pour Biggben jour 25"
## [1] 6
## [1] "Plot pour Biggben jour 30"
## [1] 7
## [1] "Plot pour Biggben jour 35"
## [1] 8
## [1] "Plot pour Biggben jour 40"
## Warning: Removed 9 rows containing missing values (`geom_segment()`).
## [1] "La profondeur max du système racinaire après 40 jours= 1599.41 [mm]"
## [1] "Le système racinaire après 40 jours s étend de-531.33[mm] à 497.27[mm] soit une largeur totale de :1028.6[mm]"
## [1] "Le diamètre moyen des racines après 40 jours est = 0.652347037621086"
## [1] 1
## [1] "Plot pour Hyperion jour 5"
## [1] 2
## [1] "Plot pour Hyperion jour 10"
## [1] 3
## [1] "Plot pour Hyperion jour 15"
## [1] 4
## [1] "Plot pour Hyperion jour 20"
## [1] 5
## [1] "Plot pour Hyperion jour 25"
## [1] 6
## [1] "Plot pour Hyperion jour 30"
## [1] 7
## [1] "Plot pour Hyperion jour 35"
## Warning: Removed 79 rows containing missing values (`geom_segment()`).
## [1] 8
## [1] "Plot pour Hyperion jour 40"
## Warning: Removed 749 rows containing missing values (`geom_segment()`).
## [1] "La profondeur max du système racinaire après 40 jours= 1514.09 [mm]"
## [1] "Le système racinaire après 40 jours s étend de-555.93[mm] à 688.48[mm] soit une largeur totale de :1244.41[mm]"
## [1] "Le diamètre moyen des racines après 40 jours est = 0.65993615261832"
## [1] 1
## [1] "Plot pour Juno jour 5"
## [1] 2
## [1] "Plot pour Juno jour 10"
## [1] 3
## [1] "Plot pour Juno jour 15"
## [1] 4
## [1] "Plot pour Juno jour 20"
## [1] 5
## [1] "Plot pour Juno jour 25"
## [1] 6
## [1] "Plot pour Juno jour 30"
## [1] 7
## [1] "Plot pour Juno jour 35"
## [1] 8
## [1] "Plot pour Juno jour 40"
## Warning: Removed 321 rows containing missing values (`geom_segment()`).
## [1] "La profondeur max du système racinaire après 40 jours= 1546.74 [mm]"
## [1] "Le système racinaire après 40 jours s étend de-622.6[mm] à 582.03[mm] soit une largeur totale de :1204.63[mm]"
## [1] "Le diamètre moyen des racines après 40 jours est = 0.634548475139433"
## [1] 1
## [1] "Plot pour Swingg jour 5"
## [1] 2
## [1] "Plot pour Swingg jour 10"
## [1] 3
## [1] "Plot pour Swingg jour 15"
## [1] 4
## [1] "Plot pour Swingg jour 20"
## [1] 5
## [1] "Plot pour Swingg jour 25"
## [1] 6
## [1] "Plot pour Swingg jour 30"
## [1] 7
## [1] "Plot pour Swingg jour 35"
## Warning: Removed 25 rows containing missing values (`geom_segment()`).
## [1] 8
## [1] "Plot pour Swingg jour 40"
## Warning: Removed 179 rows containing missing values (`geom_segment()`).
## [1] "La profondeur max du système racinaire après 40 jours= 1631.48 [mm]"
## [1] "Le système racinaire après 40 jours s étend de-510.68[mm] à 586.44[mm] soit une largeur totale de :1097.12[mm]"
## [1] "Le diamètre moyen des racines après 40 jours est = 0.634348645802182"
## [1] 1
## [1] "Plot pour Vegga jour 5"
## [1] 2
## [1] "Plot pour Vegga jour 10"
## [1] 3
## [1] "Plot pour Vegga jour 15"
## [1] 4
## [1] "Plot pour Vegga jour 20"
## [1] 5
## [1] "Plot pour Vegga jour 25"
## [1] 6
## [1] "Plot pour Vegga jour 30"
## [1] 7
## [1] "Plot pour Vegga jour 35"
## Warning: Removed 13 rows containing missing values (`geom_segment()`).
## [1] 8
## [1] "Plot pour Vegga jour 40"
## Warning: Removed 268 rows containing missing values (`geom_segment()`).
## [1] "La profondeur max du système racinaire après 40 jours= 1468.73 [mm]"
## [1] "Le système racinaire après 40 jours s étend de-643.42[mm] à 579.14[mm] soit une largeur totale de :1222.56[mm]"
## [1] "Le diamètre moyen des racines après 40 jours est = 0.62388525889266"
params_maize <- data.frame(
ageAdv = 7,
CVDD = 0.3,
dAdv = 0.3900776,
distAdv = 20,
dmax = 4.5,
dmin = 0.14,
dSem = 0.1, #0.02667,si pas ouf
EL = 32.5, #51,
erAdv = 0.8,
erSem = 0.5,
exportName = 'maize' ,
exportType = 1,
GDs = 50,
IPD = 2,
LDC = 3000,
maxAdv = 40,
maxSem = 7,
pdmax = 0.8,
pdmin = 0,
PDT = 4.5,
RDM = 0.12,
SGC = 0,
sim_length = 20,
simtime = 30,
TMD = 0.08,
TrInt = 0.01,
TrT = 1
)ArchiSimple(par=params_maize,exporttype = 1,time = 40)## [1] "Simulation pour : maize i= 1 ========================"
## # A tibble: 1 × 27
## ageAdv CVDD dAdv distAdv dmax dmin dSem EL erAdv erSem exportName
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <chr>
## 1 7 0.3 0.390 20 4.5 0.14 0.1 32.5 0.8 0.5 maize
## # ℹ 16 more variables: exportType <dbl>, GDs <dbl>, IPD <dbl>, LDC <dbl>,
## # maxAdv <dbl>, maxSem <dbl>, pdmax <dbl>, pdmin <dbl>, PDT <dbl>, RDM <dbl>,
## # SGC <dbl>, sim_length <dbl>, simtime <dbl>, TMD <dbl>, TrInt <dbl>,
## # TrT <dbl>
setwd("ArchiSimple/src/archisimple93/")
maize <- fread('maize.txt') %>%
mutate(sim='maize')
setwd("../../../") time_plot(data = maize,variety = 'maize')## [1] 1
## [1] "Plot pour maize jour 5"
## [1] 2
## [1] "Plot pour maize jour 10"
## [1] 3
## [1] "Plot pour maize jour 15"
## [1] 4
## [1] "Plot pour maize jour 20"
## [1] 5
## [1] "Plot pour maize jour 25"
## [1] 6
## [1] "Plot pour maize jour 30"
## [1] 7
## [1] "Plot pour maize jour 35"
## [1] 8
## [1] "Plot pour maize jour 40"
print(paste('La profondeur max du système racinaire=',max(maize$Z1),'[mm]'))## [1] "La profondeur max du système racinaire= 1470.92 [mm]"
print(paste0('Le système racinaire s étend de',min(maize$X1),'[mm] à ',max(maize$X1),'[mm] soit une largeur totale de :', max(maize$X1)-min(maize$X1),'[mm]'))## [1] "Le système racinaire s étend de-271.7[mm] à 213.86[mm] soit une largeur totale de :485.56[mm]"
print(paste('Le diamètre moyen des racines est =',mean(maize$Diam)))## [1] "Le diamètre moyen des racines est = 0.57440916271722"
La fonction archiDART::root donne les attributs de chaque racine.